package array
{
	import flash.utils.ByteArray;
	
	import data.Script;
	
	import tag.doABC2.CPool;
	
	import util.BytesUtil;
	import util.TraitUtil;

	public dynamic class ScriptArray extends Array
	{
		public function ScriptArray(...parameters)	
		{
			super(parameters);
		}
		
		public function fill(bytes:ByteArray):void
		{
			var cp:CPool = App.cp;
			var count:uint = BytesUtil.readU30(bytes);
			if(count > 0){
				var script:Script = null;
				for(var i:int = 0;i < count; i++){
					script = new Script();
					this[i] = script;
					script.init = BytesUtil.readU30(bytes);
					var trait_count:uint = BytesUtil.readU30(bytes);
					for(var t:int = 0; t< trait_count; t++){
						script.traits[i] = TraitUtil.trait(bytes,cp);
					}
				}
			}
		}
		
		
	}
}